import { Component, OnInit } from 'angular2/core';
import { Hero } from '../../model/hero';
import { HeroService } from '../../fasade/hero.service';
import { Router } from 'angular2/router';

@Component({
    selector: 'my-dashboard',
    templateUrl: 'app/bundles/dashboard/tpls/component.html'
})
export class DashboardComponent implements OnInit {
    heroes: Hero[] = [];
    
    constructor(
        private _heroService: HeroService,
        private _router: Router
    ) {}
    
    ngOnInit() {
        this._heroService.getHeroes()
            .then(heroes => this.heroes = heroes.slice(1,5));
    }
    
    gotoDetail(hero: Hero) {
        let link = ['Heroes','HeroDetail', { id: hero.id}];
        this._router.navigate(link);
    }
}